import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;

public class RunoobTest {

    public static void main(String[] args) {
        ArrayList<String> sites = new ArrayList<String>();
        sites.add("Google");
        sites.add("Runoob");
        sites.add("Taobao");
        sites.add("Weibo");
        sites.set(2,"123123");
        sites.remove(3);
        System.out.println(sites);
        System.out.println(sites.size());

        for (int i = 0; i < sites.size(); i++) {
            System.out.println(sites.get(i));
        }

        Iterator<String> it = sites.iterator();

        // 输出集合中的第一个元素
        System.out.println("---------------");
        System.out.println(it.next());
        System.out.println(it.next());


        System.out.println("---------------");

        // 用for-each
        for (String i : sites) {
            System.out.println(i);
        }


        ArrayList<Integer> myNumbers = new ArrayList<Integer>();

        myNumbers.add(20);
        myNumbers.add(25);
        myNumbers.add(10);
        myNumbers.add(15);
        for (int i : myNumbers) {
            System.out.println(i);
        }

        // 排序


        Collections.sort(myNumbers);  // 数字排序

        for (int i : myNumbers) {
            System.out.println(i);
        }

    }
}
